
layui.use(['flow','jquery', 'laytpl','form'] , function(){
    var form = layui.form;
    form.on('submit(searchForm)', function(data){
        var keywords=$("#keywords").val();
        if(keywords==null || keywords==""){
            layer.msg('请输入要搜索的关键字');
            return false;
        }
        search();
        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });
    
   
});



$(function(){
    $(".fa-file-text").parent().parent().addClass("layui-this");
    var keywords=$("#keywords").val();
    $("#keywords").keydown(function (event) {
        if (event.keyCode == 13) {
            var keyword=$("#keywords").val();
            if(keyword==null || keyword==""){
                layer.msg('请输入要搜索的关键字');
                return false;
            }
            search();
        }
    });
});

function search() {
	layer.msg('暂时不支持搜索！');
}

function classifyList(id) {

	$("#parentArticleList").remove();
    $(".animated.zoomIn").remove();
   $("#searchA").append('<div id="parentArticleList" ></div>');
	layui.use(['flow','jquery', 'laytpl'] ,function(){
		 var flow = layui.flow;
		  var $ = layui.jquery;
		    
		var laytpl = layui.laytpl;
		var laid=id;
		var count;
		//按要求搜索显示
		  //加载数据
		  flow.load({
			  elem: '#parentArticleList', //指定列表容器
			  isAuto:false,
			  done: function(page, next){
				  var lis = [];
				 
				  $.ajax({
		      			url: getRootPath()+'/action/article/list',
		      			type:'post',
		      			data:{
		      				page:page,
		      				lable_id:laid
		      			},
		      			dataType: 'json',
		      			success: function(data) {
		      				count = data.count;
		      				
		      				var tpl = $('#articlelist').html();
		      				laytpl(tpl).render(data, function(html){
		      					lis.push(html);
		      				});
		      				/*进行自定义标签读取*/
		      				$.post(getRootPath()+'/action/sort/list',function(data){
		      					switch(data.sort_alias){
		      					case 4:$('.article_is_top').html(data.sort_name);break;
		      					case 2:$('.article_is_yc').html(data.sort_name);break;
		      					case 1:$('.article_is_zz').html(data.sort_name);break;

		      					}
		      		
		      				});
		      			
		      				next(lis.join(''), page < count);  
		      			} 
		      		
		      		});	
			   
			  		
				  
			  }
		  });
		
		
	});
	

}
